package com.haixiaoke.saas.order.state.role;

import com.haixiaoke.saas.common.enums.OrderStateEnum;
import com.haixiaoke.saas.order.domain.Order;
import com.haixiaoke.saas.order.state.server.IOrderStateServerRole;

/**
 * 续租已支付订单状态服务角色
 * @Author panda
 * @Date 2024/5/25
 **/
public class ReletPaidOrderOrderStateServerRole extends AbstractSpecificOrderOrderStateServerRole {

    public ReletPaidOrderOrderStateServerRole(IOrderStateServerRole stateServerRole) {
        super(stateServerRole);
    }

    @Override
    public int orderCompletion(Order order, String recordSource, Long operatorId) {
        addOrderStateRecord(order.getOrderId(), order.getOrderState(), OrderStateEnum.ORDER_STATE_RELET_COMPLETED.getValue(), recordSource, operatorId);
        order.setOrderState(OrderStateEnum.ORDER_STATE_RELET_COMPLETED.getValue());
        return orderService.updateOrderBySystem(order);
    }
}
